<script setup>
import { onMounted } from 'vue'
// This starter template is using Vue 3 <script setup> SFCs
// Check out https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup
import HelloWorld from './components/HelloWorld.vue'

const imread = (src) => {
  return new Promise((resolve) => {
    let img = new Image()
    img.src = src
    img.onload = () => {
      let mat = cv.imread(img)
      resolve(mat)
    }
  })
}

const init = async () => {
  let img = await imread('./house.jpg')
  let mask = await imread('./mask.jpg')
  let mask_gray = new cv.Mat()
  cv.cvtColor(mask, mask, cv.COLOR_RGB2GRAY)
  cv.threshold(mask, mask, 170, 255, cv.THRESH_BINARY)
  let dst = new cv.Mat()
  cv.bitwise_and(img, img, dst, mask)
  // cv.inpaint(img, mask, dst, 30, cv.INPAINT_NS)
  cv.imshow('canvasOutput', dst)
}


onMounted(init)
</script>

<template>
  <canvas id="canvasOutput"></canvas>
  <img alt="Vue logo" src="./assets/logo.png" />
  <HelloWorld msg="Hello Vue 3 + Vite" />
</template>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
  background-color: #000;
}
</style>
